<template>
  <div>
    <van-dialog
      v-model="isShow.isShow"
      class="dialog"
      :before-close="auditClose"
      :showCancelButton='true'
      title="修改打卡学员"
    >
     <div class="floor">
        <div class="line2 c-666 fs25 pb6">批次：{{submitParams.batchNo}}</div>
        <div class="line2 c-666 fs25 pb6">打卡机编号：{{submitParams.deviceNo}}</div>
        <div class="line2 c-666 fs25 pb6">学员：{{submitParams.studentName}}</div>
        <div class="line2 c-666 fs25 pb6">身份证号：{{submitParams.idCard}}</div>
        <div class="line2 c-666 fs25 pb6">车型：{{findRemoteParamsText('driving_license', submitParams.drivingLicense)}}</div>
        <div class="line2 c-666 fs25 pb6">政策类型：{{findRemoteParamsText('policy_type', submitParams.policyType)}}</div>
         <div class="line2 c-666 fs25 pb6">时间段：{{findRemoteParamsText('time_phase', submitParams.timePhase)}}</div>
         <div class="line2 c-666 fs25 pb6">科二打卡状态：{{findRemoteParamsText('sign_status', submitParams.signStatus)}}</div>
         <div class="line2 c-666 fs25 pb6">科三打卡状态：{{findRemoteParamsText('sign_status', submitParams.sign3Status)}}</div>
        <div class="line2 c-666 fs25 pb6">计划开始时间：{{formatDate(submitParams.planStartDate, {outType: 'YMD'})}}</div>
        <div class="line2 c-666 fs25 pb6">计划结束时间：{{formatDate(submitParams.planEndDate, {outType: 'YMD'})}}</div>
      </div>
    </van-dialog>
  </div>
</template>

<script>
export default {
  name: '',
  components: {},
  props: {
    isShow: {
      type: Object,
      default: {isShow: false}
    },
    type: {
      type: Number,
      default: 2
    },
    info: {
      type: Object,
      required: true
    },
    chooseStudentInfo: {
      type: Object, // 为标志学员打卡选择的学员带过来的信息
      default: {}
    }
  },
  data () {
    return {
      submitParams: {
        batchNo: '',
        deviceNo: '',
        drivingLicense: '',
        id: '',
        idCard: '',
        planEndDate: '',
        planStartDate: '',
        policyType: '',
        studentId: '',
        studentName: '',
        timePhase: '',
        sign3Status: '',
        signStatus: ''
      }
    }
  },
  computed: {},
  watch: {
    'isShow.isShow' (newVal) {
      if (newVal) {
        this.submitParams = {
          batchNo: this.chooseStudentInfo.batchNo,
          deviceNo: this.chooseStudentInfo.deviceNo,
          drivingLicense: this.info.drivingLicense,
          idCard: this.info.idCard,
          planEndDate: this.chooseStudentInfo.planEndDate,
          planStartDate: this.chooseStudentInfo.planStartDate,
          policyType: this.info.policyType,
          studentId: this.info.id,
          id: this.chooseStudentInfo.id,
          studentName: this.info.name,
          timePhase: this.chooseStudentInfo.timePhase,
          sign3Status: this.info.sign3Status,
          signStatus: this.info.signStatus
        }
      } else {
        this.submitParams = {
          batchNo: '',
          deviceNo: '',
          drivingLicense: '',
          idCard: '',
          planEndDate: '',
          planStartDate: '',
          policyType: '',
          id: '',
          studentId: '',
          studentName: '',
          timePhase: '',
          sign3Status: '',
          signStatus: ''
        }
      }
    }
  },
  created () {},
  mounted () {},
  methods: {
    auditClose (action, done) {
      if (action === 'confirm') {
        // console.log('提交参数', this.submitParams)
        this.$axios
          .post('/api/clock/arrange/edit', this.submitParams)
          .then(res => {
            if (res.data.meta.success) {
              this.Toast.success('修改打卡学员成功！')
              done()
              this.$router.push('/MarkStudents')
            } else {
              done(false)
            }
          })
      } else {
        done()
      }
    }
  }
}
</script>

<style scoped lang="scss">
.dialog /deep/ .van-dialog__header{
    background-color: #f59a23;
    padding-bottom: 0.1rem
}
.dialog /deep/ .van-field__body{
  border: 1px solid #e6e6e6
}
.floor {
  padding: 0.2rem;
}
</style>
